package com.zhao.dota.util;

import com.zhao.dota.contant.IconSizeConst;
import org.springframework.util.StringUtils;

public class SteamUtil {

    private static final String HERO_ICON_URL = "https://cdn.cloudflare.steamstatic.com/apps/dota2/images/dota_react/heroes/";

    private static final String ITEM_ICON_URL = "https://cdn.dota2.com/apps/dota2/images/items/";

    private static final String ABILITY_ICON_URL = "https://cdn.cloudflare.steamstatic.com/apps/dota2/images/dota_react/abilities/";

    public static String getIconUrlByHeroName(String name) {
        if (StringUtils.hasText(name) && name.startsWith("npc_dota_hero_")) {
            return HERO_ICON_URL + name.replace("npc_dota_hero_", "") + ".png";
        }
        return "";
    }

    public static String getIconUrlByItemName(String name) {
        if (name.startsWith("item_")) {
            return ITEM_ICON_URL + name.replace("item_", "") + "_" + IconSizeConst.LARGE.getDesc();
        }
        return "";
    }

    public static String getIconUrlByAbilityName(String name) {
        return ABILITY_ICON_URL + name + ".png";
    }

    public static int getShortSteamId(Long steamId) {
        return (int) (steamId - 76561197960265728L);
    }

    public static long getSteamId(int shortSteamId) {
        return 76561197960265728L + shortSteamId;
    }

}
